import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_types.dart';
import 'package:xindong/manager/xindong_page_singleton.dart';
import 'package:xindong/manager/xindong_user_controller.dart';
import 'package:xindong/models/user/xindong_user.dart';
import 'package:xindong/routes/tab_home/controller/xindong_search_vm.dart';
import 'package:xindong/routes/tab_home/view/xindong_user_list_cell.dart';
import 'package:xindong/widgets/common/xindong_app_bar.dart';
import 'package:xindong/widgets/common/xindong_common_widget.dart';
import 'package:xindong/widgets/container/xindong_empty_container.dart';
import 'package:xindong/widgets/container/xindong_getx_builder_container.dart';

class XinDongSearchResultYeMian extends StatelessWidget {
  const XinDongSearchResultYeMian({super.key});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => FocusScope.of(context).requestFocus(FocusNode()), // 触摸收起键盘
      child: Scaffold(
        appBar: XinDongAppBar("搜索结果"),
        body: XinDongGetBuilder<XinDongHomeSearchVM>(builder: (viewClass) {
          return XinDongRefreshContainer(
            viewClass: viewClass,
            child: XinDongEmptyContainer(
              dataList: viewClass.dataList,
              emptyTips: "无相关搜索内容",
              child: ListView.separated(
                controller: viewClass.scrollController,
                itemCount: viewClass.dataList?.length ?? 0,
                itemBuilder: (BuildContext context, int index) {
                  final model = viewClass.dataList![index];
                  return XinDongUserListCell(model: model, isSearch: true);
                },
                separatorBuilder: (BuildContext context, int index) {
                  if (index + 1 == viewClass.dataList?.length) {
                    return const SizedBox();
                  }
                  return commonDivider(backgroundColor: DZColors.cellColor);
                },
              ),
            ),
          );
        }),
      ),
    );
  }
}
